package com.sanniu.service.provider;

import com.jfinal.plugin.activerecord.Db;
import io.jboot.aop.annotation.Bean;
import com.sanniu.service.SmsVcodeRecordService;
import com.sanniu.model.SmsVcodeRecord;
import io.jboot.service.JbootServiceBase;

import java.util.Date;


@Bean
public class SmsVcodeRecordServiceProvider extends JbootServiceBase<SmsVcodeRecord> implements SmsVcodeRecordService {

    @Override
    public int findCountByMobile(String mobile, Date beginTime, Date endTime) {
        System.out.println(mobile);System.out.println(beginTime);
        return Db.queryInt("select count(*) from sms_vcode_record where mobile = ? and create_time >= ? and create_time <= ?", mobile, beginTime, endTime);
    }

    @Override
    public SmsVcodeRecord findLeatestVcodeRecord(String mobile) {
        return DAO.findFirstByColumn("mobile",mobile,"create_time desc");
    }
}